package ide.ccf.ccdesigner.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;
import ide.ccf.ccdesigner.views.embedded.PropertyEditorW;

import ide.ccf.ccdesigner.editors.UiEditor;

/**
 * 属性编辑器视图
 *
 */
public class PropertyEditorView extends ViewPart implements IPartListener 
{
    private PropertyEditorW propertyeditor;

    /**
     * 创建Part控制
     */
    public void createPartControl(Composite parent) 
    {
        propertyeditor = new PropertyEditorW(parent, SWT.EMBEDDED);
        getSite().getPage().addPartListener(this);
    }

    /**
     * 设置焦点
     */
    public void setFocus() 
    {
        propertyeditor.setFocus();
    }

    /**
     * 释放
     */
    public void dispose() 
    {
        getSite().getPage().removePartListener(this);
        super.dispose();
    }

    /**
     * 激活IWorkbenchPart
     */
    public void partActivated(IWorkbenchPart part) 
    {
        IEditorPart editor = getSite().getPage().getActiveEditor();
        
        if (editor instanceof UiEditor) 
        {
            return;
        }
        propertyeditor.clearSheet();
    }
    
    /**
     * IWorkbenchPart显示到顶端
     */
    public void partBroughtToTop(IWorkbenchPart part) 
    {
    	
    }
    
    /**
     * IWorkbenchPart关闭
     */
    public void partClosed(IWorkbenchPart part) 
    {
    	
    }
    
    /**
     * IWorkbenchPart取消激活
     */
    public void partDeactivated(IWorkbenchPart part) 
    {
    	
    }
    
    /**
     * IWorkbenchPart打开
     */
    public void partOpened(IWorkbenchPart part) 
    {
    	
    }
}
